﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace HRProject.Code.DTO
{
    public class BLDailyWorktime
    {
        private Guid agentId;
        private DateTime date;
        private Guid updateUserId;
        private DateTime updateDate;
        private int leaveMorning;
        private int leaveAfternoon;
        private long dataSignature;
        private string agentFullName;
        private List<BLOverWorktime> overWorktimes;

        public List<BLOverWorktime> OverWorktimes
        {
            get { return overWorktimes; }
            set { overWorktimes = value; }
        }

        public string AgentFullName
        {
            get { return agentFullName; }
            set { agentFullName = value; }
        }

        public long DataSignature
        {
            get { return dataSignature; }
            set { dataSignature = value; }
        }

        public int LeaveAfternoon
        {
            get { return leaveAfternoon; }
            set { leaveAfternoon = value; }
        }

        public int LeaveMorning
        {
            get { return leaveMorning; }
            set { leaveMorning = value; }
        }

        public DateTime UpdateDate
        {
            get { return updateDate; }
            set { updateDate = value; }
        }

        public Guid UpdateUserId
        {
            get { return updateUserId; }
            set { updateUserId = value; }
        }

        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }

        public Guid AgentId
        {
            get { return agentId; }
            set { agentId = value; }
        }

        public float Total
        {
            get
            {
                float morning = (leaveMorning == 0 ? 0.5F : 0);
                float afternoon = (leaveAfternoon == 0 ? 0.5F : 0);
                return morning + afternoon;
            }
        }

        public float TotalOver
        {
            get
            {
                float result = 0;
                foreach (BLOverWorktime ov in overWorktimes)
                {
                    result += ov.Total;
                }
                return result;
            }
        }

        public BLDailyWorktime(Guid agentId, DateTime date)
        {
            this.agentId = agentId;
            this.date = date;
            this.overWorktimes = new List<BLOverWorktime>();
        }
    }
}
